package com.example.activitylifecycle;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button bt1 = (Button)findViewById(R.id.button);
        Button bt2 = (Button)findViewById(R.id.button3);
        EditText et1 = (EditText)findViewById(R.id.editTextTextPersonName);
        bt1.setOnClickListener(v -> {
            Intent intent = new Intent(this,NewActivity.class);
            Bundle bd=new Bundle();
            bd.putString("k",et1.getText().toString());
            intent.putExtras(bd);
            startActivityForResult(intent,0);
        });
        bt2.setOnClickListener((v)->{
            finish();
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
        Toast.makeText(this, "准备输入!!!",Toast.LENGTH_LONG).show();
    }
    @Override
    protected void onStart() {
        super.onStart();
//        Toast.makeText(this, "欢迎来到主界面!!!",Toast.LENGTH_LONG).show();
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        Toast.makeText(this, "欢迎回回回到主界面!!!",Toast.LENGTH_LONG).show();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Toast.makeText(this, "您已退出程序!!!",Toast.LENGTH_LONG).show();
    }
}